<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
		<style>
			#loginForm {
				
				background-color: lightblue;
				width: 300px;
				margin: 200px auto;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div id="loginForm" v-if="!isLogin">
				<h1 style="text-align: center;">用户注册</h1>
				<div>用户名:<input type="text" v-model="regitserInfo.username" /></div>
				<div>密码:<input type="password" v-model="regitserInfo.password"/></div>
				<div>重复密码:<input type="password" v-model="regitserInfo.repassword"/></div>
				<div>
				用户性别:
				<input type="radio" v-model="regitserInfo.gender" value="1">男
				<input type="radio" v-model="regitserInfo.gender" value="2">女
				</div>
				爱好:
				<input type="checkbox" value='听音乐' v-model="regitserInfo.likes"/>听音乐
				<input type="checkbox" value='唱歌' v-model="regitserInfo.likes"/>唱歌
				<input type="checkbox" value='打游戏' v-model="regitserInfo.likes"/>打游戏
				<input type="checkbox" value='看电影' v-model="regitserInfo.likes"/>看电影
				<div>
					学历
				<select v-model="regitserInfo.study_level">
					<option disabled value="">请选择你的学历</option>
					<option>小学</option>
					<option>初中</option>
					<option>高中</option>
					<option>大专</option>
					<option>本科</option>
					<option>研究生</option>
				</select><br />
				</div>
				<div>
					用户简介:<textarea v-model="regitserInfo.into" rows="10" cols="40"></textarea>
				<div>
					<input type="checkbox" v-model="regitserInfo.agree" /> 同意用户协议
					</div>
				</div>
				
				<div><button @click="register">注册</button></div>
			</div>
			<div v-else>
				{{username}}已登录<br />
				<div><button @click="loginOut">登出</button></div>
			</div>
		</div>

			

		<script>
			var app = Vue.createApp({
				data() {
					return {
						regitserInfo:{
							username:'',
							password:'',
							repassword:'',
							gender:'',
							likes:[],
							study_level:'',
							intro:'',
							agree:false
						},
						username:'',
						password:'',
						isLogin: false
					}
				},
				methods:{
					register:function(){
						alert("注册成功"+
						","+this.regitserInfo.username+
						","+this.regitserInfo.password+
						","+this.regitserInfo.repassword+
						","+this.regitserInfo.gender+
						","+this.regitserInfo.likes+
						","+this.regitserInfo.study_level+
						","+this.regitserInfo.agree);
					},					
					login:function(){
						if(this.username == "admin" && this.password == "123")
						{
							alert("登录成功")
							this.isLogin = true
						}
						else{
							alert("登录失败")
						}
					},
					loginOut: function(){
						this.isLogin = false;
					}
				}
			});
			var vm = app.mount("#app")
		</script>



	</body>
</html>